package com.day15.text;

public class Exam2 {
    public static void main(String[] args) {
        int[] arr = {2,5,7,8,10,15,18,20};

        int value = 18;
        int index = -1;
        int left = 0;
        int right = arr.length - 1;
        int mid = (left + right)/2;
        while(left<=right){
            //找到结束
            if(value == arr[mid]){
                index = mid;
                break;
            }//没找到
            else if(value>arr[mid]){//往右边继续查找
                right = mid +1;
            }
        }

    }
}
